<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" errorPage="" %>
<%@ page import="java.util.*" %>
<%@ page import="com.auth.domain.T_function" %>

<link rel="stylesheet" href="css/font-awesome.min.css">

<!-- 后期菜单较多或者需要查询某个菜单时再实现对应的方法即可；
<div style="position: relative; margin-top: 20px;">
<input type="text" placeholder="查找..." class="search-input cha" /> <span
style="display: inline-block; height: 35px; width: 38px; background: red; position: absolute; text-align: center; line-height: 35px; border-bottom-right-radius: 2px; border-top-right-radius: 2px; background: #374850;">
<a href="#" class="chazhao"><span class="glyphicon glyphicon-search"
style="color: white;"></span></a>
</span>
</div>
-->
<br><br>
<div class="panel-group" id="accordion"
     style="margin-top: 10px; margin-left: -12px;">

    <div class="panel panel-default">

        <%
            //String path = request.getContextPath();
			//String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
			//String systemid = request.getParameter("systemid");
            String systemid = request.getParameter("systemid");
            System.out.println("------....................leftlists.jsp getAttribute('systemid')=" + systemid);

            List functList = (List) request.getSession().getAttribute("FREE_USER_AUTH");
            StringBuffer menuInfo = new StringBuffer();
            String flag = "";
            String url = "";
            try {
                if (functList != null) {
                    Iterator it = functList.iterator();
                    while (it.hasNext()) {
                        T_function f = (T_function) it.next();
                        System.out.println("------.....................f.getSystemid()="+f.getSystemid());
						System.out.println("------.....................systemid.equals(f.getSystemid())?="+systemid.equals(f.getSystemid()) );

						//如果是等于要显示的系统菜单，才输出显示；
                        if (systemid.equals(f.getSystemid())) {
                            if (f.getFunctlevel().equals("1")  ) {
                                if (flag.equals("2")) { //第一次时为空；所以不会输出闭合；
                                    menuInfo.append("</ul></div>"); //首先闭合没有下级或者下级输出完毕的一级functname；
                                }
                                flag = "1";

                                //输出1级菜单，顺序后台已经排好；前端顺序输出即可；
                                menuInfo.append("	<div class='panel-heading'>");
                                menuInfo.append("		<a class='open-menu green-left' href='#collapse" + f.getFunctid() + "' data-toggle='collapse' data-parent='#accordion'> <span class='" + f.getPic() + "'></span> <span>" + f.getFunctname() + "</span> <span class='glyphicon glyphicon-menu-left pull-right'></span> </a>");
                                menuInfo.append("	</div>");
                                menuInfo.append("	<div id='collapse" + f.getFunctid() + "' class='panel-collapse collapse '>");
                                menuInfo.append("		<ul>");
                            }
                            if (f.getFunctlevel().equals("2")  ) {
                                //menuInfo.append("<li ><a href='"+basePath + f.getUrl()+"&functname="+f.getFunctname()+"&functid="+f.getFunctid()+"' target='mainFrame' style='color:black'><i class='"+f.getPic()+"'></i>"+f.getFunctname()+"</a></li>");
                                flag = "2";
                                //输出2级菜单，顺序后台已经排好；前端顺序输出即可；
                                //url = basePath + f.getUrl()+"&functname="+f.getFunctname()+"&functid="+f.getFunctid();
                                url = basePath + f.getUrl() + "&functname=&functid=" + f.getFunctid();
                                //System.out.println("------.....................url=" + url);
                                //menuInfo.append("		<li><a href='"+url+"' target='ranhengFrame' > <span class='"+f.getPic()+"'></span> <span>"+f.getFunctname()+"</span></a></li>");
                                menuInfo.append("		<li><a href='javascript:changepath(\"" + url + "\");'  > <span class='" + f.getPic() + "'></span> <span>" + f.getFunctname() + "</span></a></li>");
                            }
                        } //end if systemid；
                    } //end while;
                    //如果是输出到了2级结束，就不会再走到while循环，所以此次循环结束后需要再次判断是否是否要输出对等的</ul></div>封闭
                    if (flag.equals("2")) { //第一次时为空；所以不会输出闭合；
                        menuInfo.append("</ul></div>"); //首先闭合没有下级或者下级输出完毕的一级functname；
                    }
                } //end if;
                System.out.println("------.....................menuInfo=" + menuInfo.toString());
            } catch (Exception e) {
            	e.printStackTrace();
                System.out.println("加载系统菜单出错=" + e.toString() );
            }

        %>
        <%=menuInfo.toString()%>


    </div>
</div>
<script>
    $(function () {
        $(".chazhao").click(function () {
            var $val = $(".cha").val();
            $(".thistable").load("menucha", {val: $val});
        });
    })

</script>
<script src="<%=basePath%>js/bootstrap.min.js"></script>
<script src="<%=basePath%>js/jquery-1.10.2/jquery.min.js"></script>

<script type="text/javascript" src="js/bootstrapValidator.js"></script>
<script src="<%=basePath%>js/bootstrap-paginator.min.js"></script>
<script src="<%=basePath%>/js/respond.js"></script>
<script src="<%=basePath%>/js/html5.js"></script>
<script src="<%=basePath%>js/toastr/toastr.js"></script>
<script src="<%=basePath%>js/bootbox.js"></script>
<script src="<%=basePath%>js/jquery.validate.js"></script>
 <script src="<%=basePath%>js/additional-methods.min.js"></script>
<script src="<%=basePath%>js/my-jquery-curd.js"></script>
<script src="<%= basePath %>js/tableSortTool.js"></script>
<script src="<%= basePath %>js/calendar.js"></script>
<!-- -->
<script type="text/javascript">
    /*通过改变iframe来改变里面的内容块  */
    function changepath(path) {
        //alert(path);
        //$('#ranhengFrame').attr('src', path); //同级；
        $("#ranhengFrame", parent.document.body).attr("src", path); //父级;
        //alert("33333333");
    }
</script>